Skip to content

test(Toast): a fallback toast keeps its Theme under a host-themed root, in Chromium - #12995

Open
nynexman4464 wants to merge 3 commits into
mainfrom
nynexman4464/test/toast-fallback-theme-browser
Open

nynexman4464 wants to merge 3 commits into
mainfrom
nynexman4464/test/toast-fallback-theme-browser

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

The fallback toast viewport draws a toast under the Theme it was shown from (#12716). The defect behind that rule was toast text nobody could read: 1.0:1 to 1.3:1 in a page whose host renamed the theme on the root element.

The tests for the rule run in jsdom. jsdom applies no scoped theme CSS and paints nothing, so they prove which Theme wraps the card. They do not prove that the Theme's tokens reach the card or what color its text paints. A change that keeps the wrapper and breaks the cascade passes today.

Intended invariant

  • architecture:theme-application INV3: a toast in the fallback toast viewport draws under the nearest Theme of the component that showed it. The record's text before INV3 adds that a host page that rewrites <html> does not change that theme.
  • component:Toast FR14: toast text takes the color that reads best on its painted card. Its verification measures WCAG 2.2 SC 1.4.3 (4.5:1).

This pull request changes neither. It adds the real-engine evidence for both in the fallback viewport.

Change

  • A story, Core/Toast/Accessibility / Fallback viewport under a Theme: a page Theme with --radius-container: 0px, a second Theme with 24px around one region, and one button in each. The story sets the toolbar theme to none, so no LayerProvider is above it and both toasts go to the fallback viewport.
  • A Chromium spec, ToastFallbackTheme.a11y.chromium.spec.ts. It opens the story, waits for the page Theme to name itself on the root element and for Storybook's own inline root color scheme, then themes the root as a host does: a theme name the page holds no CSS for, a scheme, and the host's own text and inverted-surface colors. It shows a toast from each button and checks three things on the card: the Theme around it, its corner radius from that Theme's tokens (0px or 24px), and its text contrast. It runs under a light and a dark host; both story Themes are light.

No file that ships in a package changes. No record changes: pnpm specs:for finds the spec through the Toast folder.

Evidence

  • Failure before the change: with the caller's Theme left out of the fallback entry (the three-line spread in useToast.tsx removed), all 4 cases fail on all three checks. The card's theme is host, its radius is the default 12px instead of 0px or 24px, and the contrast is 1.0:1 under a light host and 1.3:1 under a dark host.
  • Success after the change: on main, all 4 cases pass in Chromium in 3 runs in a row (about 18 s for the file, including the Storybook server).
  • Product/runtime behavior verified unchanged: the change adds one story and one spec.
  • CI impact: no workflow, action or CI script changes. The spec's @pr-a11y scope line runs it when a pull request changes Toast, theme/ or the Toast stories.

Scope

Components: Toast

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

node .github/scripts/build-packages-and-storybook.mjs
pnpm exec playwright test ToastFallbackTheme.a11y.chromium.spec.ts --project chromium
pnpm review:pre --head HEAD

pnpm review:pre reports 0 findings, 223 authored lines and a clean merge into main.

…t, in Chromium

The fallback toast viewport draws a toast under the Theme it was shown
from. The tests for that rule run in jsdom, which applies no scoped theme
CSS and paints nothing. They prove which Theme wraps the card, not which
rules reach it or what color its text paints.

Add a story with a page Theme, a second Theme around one region, and no
LayerProvider. Add a Chromium spec that themes the root element as a host
page does, shows a toast from each Theme, and checks the theme whose rules
reach the card and the text contrast on it, in light and in dark.
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 19, 2026 9:48pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 9:50 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · adb7ed1

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Toast · Storybook 106.8 kB (0) · 11.4 kB CSS (0) 1,790 (0) ✓ · ✓ · ✓

Package size: no published package changed; no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested for one fix to the description; the story and the Chromium spec are sound.

  • The Testing section says pnpm review:pre reports 220 authored lines, but at this head it reports 223 (53 in the stories file, 170 in the spec): correct the number or drop it.

The spec passes at this head, and with the caller's Theme removed from the fallback entry it fails all four cases with the Theme, radius and contrast values the description gives.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Verified: the fallback viewport draws a toast under the Theme it was shown from (useToast.tsx:142-160, ToastViewport.tsx:392-410).
  • Verified: the existing jsdom tests assert only which Theme wraps the card (useToast.test.tsx:235-265).
  • Verified: the story's toolbar theme none leaves no Theme or LayerProvider above it (.storybook/preview.tsx:70-84).
  • Verified: the spec waits for the page Theme and Storybook's root color scheme, then themes the root as a host does (spec lines 79-97).
  • Verified: the spec checks the card's Theme, its radius from that Theme's tokens and its text contrast under a light and a dark host, with both story Themes light (spec lines 157-170).
  • Verified: with the caller's Theme removed, all 4 cases fail on all three checks (host, 12px, 1.0:1 and 1.3:1), by a red run.
  • Verified: all 4 cases pass in 3 runs in a row (12 of 12).
  • Verified: no shipped file, record, workflow or CI script changes, and the scope line runs the spec for Toast, theme and Toast-story changes.
  • False: the pre-review command reports 220 authored lines; it reports 223 (its 0 findings and clean merge hold).
  • apps/storybook/stories/Toast.stories.tsx: clear.
  • packages/core/src/Toast/__tests__/ToastFallbackTheme.a11y.chromium.spec.ts: clear.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: the pull request is a draft, so CI has not run on this head yet; it runs once the pull request is marked ready for review.

The earlier request is resolved: the Testing section's pnpm review:pre count now reads 223, which matches this head. The Chromium spec passes here and fails all four cases with the caller's Theme removed from the fallback entry, so it guards the rule it targets.

Claims and files checked

Review mode: same-head; reason: none

  • Changed rules (0): none.
  • Verified: the fallback viewport draws a toast under the Theme it was shown from, and that fix has landed on main (useToast.tsx:142-160, ToastViewport.tsx:392-410).
  • Verified: the defect was unreadable toast text, 1.0:1 to 1.3:1, under a host-renamed root, by a red run.
  • Verified: the existing jsdom tests assert only which Theme wraps the card (useToast.test.tsx:235-265).
  • Verified: the description's paraphrases of the theme-application invariant, the host-rewrite rule before it, and Toast's contrast requirement with its 4.5:1 check match the current records, and no record changes.
  • Verified: the story pins the toolbar theme to none, so no LayerProvider is above it and both toasts use the fallback viewport (.storybook/preview.tsx:70-83).
  • Verified: the spec waits for the page Theme and Storybook's root color scheme, then themes the root as a host does (spec lines 79-97).
  • Verified: the spec checks the card's Theme, its radius from that Theme's tokens and its text contrast under a light and a dark host, with both story Themes light (spec lines 157-170).
  • Verified: with the caller's Theme removed, all 4 cases fail on all three checks (host, 12px, 1.0:1 and 1.3:1).
  • Verified: all 4 cases pass in 3 runs in a row against main's Toast and theme code.
  • Verified: no shipped file, workflow or CI script changes; the spec-routing helper finds the spec through the Toast folder, and the scope line runs it for Toast, theme and Toast-story changes.
  • Verified: no public API, behavior or policy change, and no internal context in the pull request text or code.
  • Verified: the pre-review command reports 0 findings, 223 authored lines and a clean merge into main.
  • apps/storybook/stories/Toast.stories.tsx: clear.
  • packages/core/src/Toast/__tests__/ToastFallbackTheme.a11y.chromium.spec.ts: clear.

Automated review (maintainer link)

@nynexman4464
nynexman4464 marked this pull request as ready for review November 19, 2026 20:51
@nynexman4464
nynexman4464 marked this pull request as draft November 19, 2026 21:37
@nynexman4464
nynexman4464 marked this pull request as ready for review November 19, 2026 21:38

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: some required checks are still running on this head.

The merge of main leaves this pull request's own changes untouched, so the earlier approval carries forward. The Chromium spec passes all four cases in CI's accessibility contracts job on this head and fails all four with the caller's Theme removed from the fallback entry, so it guards the rule it targets.

Claims and files checked

Review mode: carry-forward; reason: none

  • Verified: the fallback viewport draws a toast under the Theme it was shown from, and that fix is on main (useToast.tsx:142-160, ToastViewport.tsx:392-410).
  • Verified: the defect was unreadable toast text, 1.0:1 to 1.3:1, under a host-renamed root, by a red run.
  • Verified: the existing jsdom tests assert only which Theme wraps the card (useToast.test.tsx:235-265).
  • Verified: the description's paraphrases of the theme-application invariant, the host-rewrite rule before it, and Toast's contrast requirement with its 4.5:1 check match the current records, and no record changes.
  • Verified: the story pins the toolbar theme to none, so no LayerProvider is above it and both toasts use the fallback viewport (.storybook/preview.tsx:70-83).
  • Verified: the spec waits for the page Theme and Storybook's root color scheme, then themes the root as a host does (spec lines 79-97).
  • Verified: the spec checks the card's Theme, its radius from that Theme's tokens and its text contrast under a light and a dark host, with both story Themes light (spec lines 157-170).
  • Verified: with the caller's Theme removed, all 4 cases fail on all three checks (host, 12px, 1.0:1 and 1.3:1).
  • Verified: all 4 cases pass in 3 runs in a row against main's Toast and theme code, and again in CI on this head after the merge of main.
  • Verified: no shipped file, workflow or CI script changes; the spec-routing helper finds the spec through the Toast folder, and the scope line runs it for Toast, theme and Toast-story changes.
  • Verified: no public API, behavior or policy change, and no internal context in the pull request text, commits or code.
  • Verified: 223 authored lines and a clean merge into main; the pre-review command reported 0 findings on this patch.
  • apps/storybook/stories/Toast.stories.tsx: clear.
  • packages/core/src/Toast/__tests__/ToastFallbackTheme.a11y.chromium.spec.ts: clear.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — adb7ed1c Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant